
<?php
    $this->headScript()->appendFile($this->baseUrl() . '/application/modules/Webmix/externals/pickcolor/Color.js/Color.js');
    $this->headScript()->appendFile($this->baseUrl() . '/application/modules/Webmix/externals/pickcolor/Source/ColorRoller.js');
    
     $this->headLink()
          ->prependStylesheet($this->baseUrl() . '/application/modules/Webmix/externals/pickcolor/Source/Assets/ColorRoller.css');
?>
<h2>
  <?php echo $this->translate('Webmix Plugin') ?>
</h2>

<script type="text/javascript">
  var fetchLevelSettings =function(level_id){
    window.location.href= en4.core.baseUrl+'admin/webmix/level/index/id/'+level_id;
    //alert(level_id);
  }
</script>

<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
      // Render the menu
      //->setUlClass()
      echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>

<div class='clear'>
  <div class='settings'>
    <?php echo $this->form->render($this) ?>
  </div>

</div>
<?php $background = $this->backgound;
        $color = $this->color;
?>
<script type="text/javascript">
        function hexToRgb(hex) {
            var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
            
            return result ? {
                r: parseInt(result[1], 16),
                g: parseInt(result[2], 16),
                b: parseInt(result[3], 16)
            } : null;
        }
        var b = hexToRgb('<?php echo $this->b?>');
        
        var c = hexToRgb('<?php echo $this->c?>');
        var create = hexToRgb('<?php echo $this->create?>');
        var country = hexToRgb('<?php echo $this->country?>');
        var tab = hexToRgb('<?php echo $this->tab?>');

        var tab_backgroudcolor = hexToRgb('<?php echo $this->tab_backgroudcolor?>');
        var activetab_backgroudcolor = hexToRgb('<?php echo $this->activetab_backgroudcolor?>');
        var admintab_color = hexToRgb('<?php echo $this->admintab_color?>');
        
        var CRImages = "<?php echo $this->baseUrl()?>/application/modules/Webmix/externals/pickcolor/Source/Assets/";
		window.addEvent('domready', function init(){
			
			new ColorRoller('webmix_backgound', {
				onComplete:function(color){
					$('webmix_backgound').set('value', color);
				},
                'color':[b.r,b.g,b.b]
			});
            
            new ColorRoller('block_color', {
				onComplete:function(color){
					$('block_color').set('value', color);
				},
                'color':[c.r,c.g,c.b]
			});
            
            new ColorRoller('create_color', {
				onComplete:function(color){
					$('create_color').set('value', color);
				},
                'color':[create.r,create.g,create.b]
			});
            new ColorRoller('countries_color', {
				onComplete:function(color){
					$('countries_color').set('value', color);
				},
                'color':[country.r,country.g,country.b]
			});
            new ColorRoller('tab_color', {
				onComplete:function(color){
					$('tab_color').set('value', color);
				},
                'color':[tab.r,tab.g,tab.b]
			});
            new ColorRoller('tab_backgroudcolor', {
				onComplete:function(color){
					$('tab_backgroudcolor').set('value', color);
				},
                'color':[tab_backgroudcolor.r,tab_backgroudcolor.g,tab_backgroudcolor.b]
			});
            new ColorRoller('activetab_backgroudcolor', {
				onComplete:function(color){
					$('activetab_backgroudcolor').set('value', color);
				},
                'color':[activetab_backgroudcolor.r,activetab_backgroudcolor.g,activetab_backgroudcolor.b]
			}); 
            new ColorRoller('admintab_color', {
				onComplete:function(color){
					$('admintab_color').set('value', color);
				},
                'color':[admintab_color.r,admintab_color.g,admintab_color.b]
			}); 
		});	
	</script>